///////////////////////////////////////////////////////////////////////////////
//
// lighthouse3D - 3D Software Library
//
// File: CCamera.h
//
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2003-2013 Marcus Reinhardt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
///////////////////////////////////////////////////////////////////////////////
//
// You can find a copy of the GNU General Public License (gpl.txt) in the
// directory of the library.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef _CCamera_H_
#define _CCamera_H_

#include <vector>

#include "CBasicClasses.h"
#include "CMathe3D.h"

///////////////////////////////////////////////////////////////////////////////
// class CCamera : Contains implementations of the camera
///////////////////////////////////////////////////////////////////////////////

//! Contains position data of the camera

struct TCamera
{
	float farClipping, nearClipping;
	float trX, trY, trZ;
	float oldtrX, oldtrY, oldtrZ;
	float colDetect;

    // for information purpose only ( getCameraInformation() )
    float angleX, angleY, angleZ;
    float camOriginX, camOriginY, camOriginZ;

    TVector3D viewVec, downVec, rightVec;
    TVector3D origViewVec, origDownVec, origRightVec;
};

//! Contains the implementation of the camera

class CCamera
{

public:

	CCamera();
	~CCamera();

	///////////////////////////////////////////////////////////////////////////////
	// Administration of the camera
	///////////////////////////////////////////////////////////////////////////////
	bool addCamera(TCamera &c);
	int  getActiveCamera();
	int  getCameraCount();
	void setActiveCamera(int i);
	void setNextCamera();
	void resetActiveCamera();
	void undoLastMove(int i);
	void setColDistance(int i, float d);
	float getColDistance(int i);

    TCamera *getCamera(int i);
    TCamera getCameraInformation(int i);

    ///////////////////////////////////////////////////////////////////////////////
    // Enhanced mathematical functions for controlling the camera
    ///////////////////////////////////////////////////////////////////////////////
    void fastRotateVector(TVector3D *v, float angleSin, float angleCos, int rotationAxis);
    void transformVector(TVector3D *vec, int i);

    ///////////////////////////////////////////////////////////////////////////////
    // Controlling the camera
	///////////////////////////////////////////////////////////////////////////////
	void moveAheadCamera(int i, float speed);
    void moveBackCamera(int i, float speed);
    void moveDownCamera(int i, float speed);
    void moveLeftCamera(int i, float speed);
    void moveRightCamera(int i, float speed);
    void moveUpCamera(int i, float speed);
    void turnAroundXAxisNegativ(int i, int angle);
    void turnAroundXAxisPositiv(int i, int angle);
    void turnAroundYAxisNegativ(int i, int angle);
    void turnAroundYAxisPositiv(int i, int angle);
    void turnAroundZAxisNegativ(int i, int angle);
    void turnAroundZAxisPositiv(int i, int angle);
    void turnDownCamera(int i, int angle);
    void turnLeftCamera(int i, int angle);
    void turnRightCamera(int i, int angle);
    void turnUpCamera(int i, int angle);
    
private:

    int             activeCamera;
	std::vector<TCamera> Cameras;
    CMathe3D        mathe3D;

};

#endif
